#ifndef _HOME_H
#define _HOME_H

#include <QtWidgets/QMainWindow>
#include <QMouseEvent>
#include <QPoint>
#include <QTimer>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonParseError>
#include <QGraphicsDropShadowEffect>
#include "log.h"
#include "resourceitem.h"
#include "httpcommon.h"
#include "ui_home.h"
#include "resource.h"
#include "upload.h"
#include "download.h"
#include "finish.h"
#include "config.h"
#include "globaldata.h"
#include "confirm.h"

extern class Login;

class Home : public QMainWindow {
	Q_OBJECT
public:
	Home(Login *login);
	~Home();
protected:
	virtual void keyPressEvent(QKeyEvent *event);
	bool eventFilter(QObject* obj, QEvent* e);
	void paintEvent(QPaintEvent *event);
	virtual void resizeEvent(QResizeEvent *event);

	public Q_SLOTS:
	void on_pbQuit_clicked();
	void on_pbMin_clicked();
	void on_pbMax_clicked();
	void on_pbNormal_clicked();
	void on_pbClose_clicked();

	private Q_SLOTS:
	void downloadSlot(QString streamID, QString name, bool showMsg);
	void uploadSlot(QString dirID);
	void quitConfigSlot();
	void confirmOKSlot();
	void showMessageSlot(QString, int);
	void clearTimerMessage();

private:
	void initWidget();
	void setPageIndex(int index);
	void resetWidget();

private:
	Ui::Home ui;
	Login *m_login;

	QPoint m_windowPos;
	QPoint m_mousePos;
	QPoint m_dPos;

	Resource *m_resource;
	Upload *m_upload;
	Download *m_download;
	Finish *m_finish;
	Config *m_config;
	QString m_confirmType;
	QTimer m_msgTimer;
	QLabel *m_lblMsg;
	QWidget *m_shadowWidget;

	int m_currentPageIndex;
	int m_currentTransPageIndex;
};

#endif//_HOME_H
